package com.example.camerademo.countdownview

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.camerademo.R

class RecyViewActivity : AppCompatActivity() {


    lateinit var mMyAdapter: MyAdapter
    private lateinit var mDataList: MutableList<ItemInfo>
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_recy_view)

        initData()
        mMyAdapter = MyAdapter(mDataList);
        val mRecyclerView = findViewById<RecyclerView>(R.id.mRecyclerView)
        mRecyclerView.layoutManager = LinearLayoutManager(this)
        mRecyclerView.adapter = mMyAdapter;

    }

    private fun initData() {
        mDataList = ArrayList()
        for (i in 1..19) {
            mDataList.add(ItemInfo(1000 + i, "RecyclerView_测试标题_$i", (i * 20 * 1000).toLong()))
        }

        // 校对倒计时
        val curTime = System.currentTimeMillis()
        for (itemInfo in mDataList) {
            itemInfo.setEndTime(curTime + itemInfo.getCountdown())
        }
    }
}